package org.jeecg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.domain.dto.HistoryOrdersDto;
import org.jeecg.domain.po.HistoryOrdersServeSync;
import org.jeecg.service.HistoryOrdersServeSyncService;
import org.jeecg.mapper.HistoryOrdersServeSyncMapper;
import org.jeecg.utils.ResponseResult;
import org.springframework.stereotype.Service;

/**
* @author 32327
* @description 针对表【history_orders_serve_sync(服务单)】的数据库操作Service实现
* @createDate 2024-12-30 18:18:19
*/
@Service
public class HistoryOrdersServeSyncServiceImpl extends ServiceImpl<HistoryOrdersServeSyncMapper, HistoryOrdersServeSync>
    implements HistoryOrdersServeSyncService{

    @Override
    public ResponseResult findPage(HistoryOrdersDto dto) {
        IPage page = new Page(dto.getPageNum(), dto.getPageSize());
        LambdaQueryWrapper<HistoryOrdersServeSync> wrapper = Wrappers.<HistoryOrdersServeSync>lambdaQuery()
                .eq(dto.getServeStatus() != null, HistoryOrdersServeSync::getServeStatus, dto.getServeStatus())
                .eq(HistoryOrdersServeSync::getIsDeleted, 0)
                .eq(HistoryOrdersServeSync::getServeProviderType, 2);
        this.page(page, wrapper);
        return ResponseResult.okResult(page.getRecords());
    }

    @Override
    public ResponseResult getOneById(String id) {
        if (id == null) {
            return ResponseResult.errorResult(500, "id为空");
        }
        HistoryOrdersServeSync historyOrdersServeSync = this.getOne(Wrappers.<HistoryOrdersServeSync>lambdaQuery()
                .eq(HistoryOrdersServeSync::getId, id)
                .eq(HistoryOrdersServeSync::getIsDeleted, 0)
                .eq(HistoryOrdersServeSync::getServeProviderType, 2));
        return ResponseResult.okResult(historyOrdersServeSync);
    }
}




